﻿<!DOCTYPE html>
<html>
<head>
    <title>会穿的人儿都在抽中秋大奖</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="telephone=no" name="format-detection" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/mdialog.css">
     
    <style>
        body
        {
            background: #222657;
            overflow-x: hidden;
            font-family: 微软雅黑;
        }
        .bg
        {
            width: 100%;
            height: auto;
            margin: 0px;
            padding: 0px;
        }
        .bg-img
        {
            width: 100%;
            height: 100%;
            position: absolute;
            top: 0px;
            left: 0px;
        }
        .g-lottery-case
        {
            width: 50%;
            height: 500px;
            margin: 0 auto;
            overflow: hidden;
            background: #ccc;
            position: absolute;
            z-index: 20000;
        }
        .g-lottery-box .playbtn
        {
            width: 201px;
            height: 201px;
            position: absolute;
            top: 44%;
            left: 33%;
            background: url(img/lottery/抽奖-OK-01.png) no-repeat;
        }
        .rotate_wrap
        {
            width: 100%;
            max-width: 300px;
            height: 300px;
            margin: 180px auto 20px;
            position: relative;
        }
        .bg_img
        {
            width: 100%;
            position: absolute;
            top: 0;
            left: 0;
        }
        .cont_img
        {
            width: 100px;
            position: absolute;
            top: 100px;
            left: 98px;
        }
        .rotate_origin
        {
            transform-origin: 50% 50%;
            -ms-transform-origin: 50% 50%;
            -webkit-transform-origin: 50% 50%;
            -moz-transform-origin: 50% 50%;
            -o-transform-origin: 50% 50%;
        }
        .rotate_origin1
        {
            transform-origin: 50% 85%;
            -ms-transform-origin: 50% 85%;
            -webkit-transform-origin: 50% 85%;
            -moz-transform-origin: 50% 85%;
            -o-transform-origin: 50% 85%;
        }
        .container
        {
            display: block;
            position: absolute;
            margin: 50px auto;
            top: 50px;
            width: 80%;
            float: left;
            right: 0px;
            left: 0px;
        }
        
        .show-p
        {
            position: relative;
            float: left;
            width: 100%;
            border: none;
            border-radius: 5px;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.7);
            background: #fff;
            text-align: center;
            font-size: 20px;
        }
        .show-img
        {
            padding-top: 10px;
        }
        .cusbtn
        {
            display: block;
            width: 100%;
            height: 50px;
            padding: 0;
            background: #e26e54;
            line-height: 50px;
            text-align: center;
            text-decoration: none;
            text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.3);
            font-size: 1.2em;
            font-family: "microsoft yahei";
            font-weight: 400;
            color: #fff;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-shadow: 0 0 0 transparent;
        }
        .frow
        {
            float: left;
            display: block;
            width: 100%;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>
    <img class="bg-img"src="img/til-bg.jpg"/>
    <img class="bg-img" src="img/lottery/抽奖-OK-16.png" />
    <div class="rotate_wrap">
        <img class="bg_img rotate_origin" id="i_bg" src="img/lottery/抽奖-OK-17.png">
        <img class="cont_img rotate_origin1" id="i_cont" src="img/lottery/playbtn.png">
        <div style="position: fixed; bottom: 0px; left: 0px; right: 0px; color: #fff; font-size: 12px;
            text-align: center; width: 100%;">
            本次活动最终解释权归广州卡门实业有限公司所有。
        </div>
    </div>
    <div id="msg1" class="container" style="display: none;">
        <div class="show-p">
            <div class="show-img">
                <img id="myimg" src="img/img1.png" />
            </div>
            <div>
                恭喜您
            </div>
            <div>
                获得<span style="color: Red;" id="prdname">中秋巨无比大礼包</span>
            </div>
            <div id="des" style="color: Red;">
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpay" class='cusbtn' href='#'>去领奖</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg2" class="container" style="display: none;">
        <div class="show-p" style="font-size: 18px;">
            <div class="show-img">
                <img id="Img1" src="img/img4.png" />
            </div>
            <div>
                呜呼！差一点就中奖了！
            </div>
            <div>
                然而，什么都没有
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpayno" class='cusbtn' href='#'>我不信</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <div id="msg3" class="container" style="display: none;">
        <div class="show-p" style="font-size: 18px;">
            <div class="show-img">
                <img id="Img2" src="img/img4.png" />
            </div>
            <div>
                对不起
            </div>
            <div>
                您的抽奖机会已用完
            </div>
            <div class="frow">
                <div style="padding: 10px 20px;">
                    <a id="btnpayun" class='cusbtn' href='#'>我不信</a>
                </div>
            </div>
            <div>
                <img src="img/bt-bg.png" style="width: 100%" />
            </div>
        </div>
    </div>
    <script src="js/jquery-1.8.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript" src="js/jquery.rotate.min.js"></script>
    <script src="js/Script.js" type="text/javascript"></script>
    <script type="text/javascript" src="js/zepto.min.js"></script>
    <script type="text/javascript" src="js/mdialog.js"></script>
    <script language="javascript" type="text/javascript">
       /* $(function () {
            //分享接口验证
            $.ajax({
                url: url_path + "/AjaxContrls/UnitControler.aspx",
                type: "POST",
                data: { aciton: 'getwxconfig' },
                timeout: 30000,
                dataType: "json",
                success: function (data) {
                    if (data.status == 0) {
                        wx.config({
                            debug: true, //这里是开启测试，如果设置为true，则打开每个步骤，都会有提示，是否成功或者失败
                            appId: data.appid,
                            timestamp: data.timestamp, //这个一定要与上面的php代码里的一样。
                            nonceStr: data.nonceStr, //这个一定要与上面的php代码里的一样。
                            signature: data.signature,
                            jsApiList: ['onMenuShareTimeline']
                        });
                        wx.ready(function () {
                            wx.onMenuShareTimeline({
                                title: "会穿的人儿都在抽中秋大奖", // 分享标题
                                link: "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx6d3a3a25e9576db6&redirect_uri=http%3A%2F%2Fweixin.km-china.cn%2Fkmwx%2Flottery.html&response_type=code&scope=snsapi_base&state=123", // 分享链接
                                imgUrl: "http://mmbiz.qpic.cn/mmbiz_jpg/70KUcLjnuYAvck2NBNibicPURFVwE80ia5UrQ8E3DEad4ZKW2JwOR9XhzKvf92vGxEogUE2vlCqYALkFpUomBY0qw/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1", // 分享图标
                                success: function () {
                                    alert("分享成功！");
                                },
                                cancel: function () {
                                    // 用户取消分享后执行的回调函数
                                    alert("取消分享！");
                                }
                            });
                        });
                    } else {
                        alert("出现问题");
                    }
                },
                error: function () {
                    alert("数据超时！");
                }
            });
            
        });*/
    </script>
    <script>
        var playnum = 0;
        var openid = null;
        var pid;
        var $btn = $('.cont_img');
        $(function () {
            openid = $.getUrlParam('openid');
            var code = $.getUrlParam('code');
            getopenid(code);
            //初始次数，由后台传入
            $('.playnum').html(playnum);
            var isture = 0;
            var clickfunc = function () {
                var data = [1, 2, 3, 4, 5];
                //data为随机出来的结果，根据概率后的结果
                var rd = Math.random();
                data = data[Math.floor(rd * data.length)];
                if (data == 4 || data == 5) {
                    goto(data);
                } else
                    checkstock(data);
            }
            $("#btnpay").live("click", function () {
                window.location.href = 'address.html?openid=' + openid + '&pid=' + pid;
            });
            $("#btnpayno").live("click", function () {
                window.location.href = 'http://mp.weixin.qq.com/s?__biz=MzIwMTA1NjEzOQ==&mid=2651136492&idx=1&sn=b4841f8e0c4a583586bf57d4d97d2ca6&scene=0#wechat_redirect';
            });
            $("#btnpayun").live("click", function () {
                window.location.href = 'http://mp.weixin.qq.com/s?__biz=MzIwMTA1NjEzOQ==&mid=2651136492&idx=1&sn=b4841f8e0c4a583586bf57d4d97d2ca6&scene=0#wechat_redirect';
            });
            function goto(data) {
                switch (data) {
                    case 1:
                        rotateFunc(1, -40, '中秋巨无比大礼包');
                        break;
                    case 2:
                        rotateFunc(2, 30, '北欧风味月饼礼盒');
                        break;
                    case 3:
                        rotateFunc(3, 110, '7天连锁全国通用豪华房');
                        break;
                    case 4:
                        rotateFunc(4, 180, '然而，什么都没有');
                        break;
                    case 5:
                        rotateFunc(5, 250, '再来一次');
                        break;
                }
            }
            function getopenid(code) {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'getwxopenid', code: code },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        playnum = data.status;
                        openid = data.openid;
                        $btn.click(function () {
                            if (isture) return; // 如果在执行就退出
                            isture = true; // 标志为 在执行
                            //先判断是否登录,未登录则执行下面的函数
                            if (1 == 2) {
                                $('.playnum').html('0');
                                alert("请先登录");
                                isture = false;
                            } else { //登录了就执行下面
                                if (playnum <= 0) { //当抽奖次数为0的时候执行
                                    //alert("对不起，您已经抽过奖！");
                                    $("#msg3").show();
                                    $('.playnum').html(0);
                                    isture = false;
                                } else { //还有次数就执行
                                    playnum = playnum - 1; //执行转盘了则次数减1
                                    if (playnum <= 0) {
                                        playnum = 0;
                                    }
                                    $('.playnum').html(playnum);
                                    btnplay();
                                }
                            }
                        });
                    },
                    error: function () {
                        alert("");
                    }
                });
            }
            function btnplay() {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'updwxopenid', openid: openid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            clickfunc();
                        } else if (data.status == 1) {
                            alert("您已经抽过奖！");
                        }
                    },
                    error: function () {
                        alert("数据超时！");
                    }
                });
            }
            function againplay() {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'updwxpaynum', openid: openid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            playnum = 1;
                        }
                    },
                    error: function () {
                    }
                });
            }
            function checkstock(pid) {
                $.ajax({
                    url: url_path + "/AjaxContrls/UnitControler.aspx",
                    type: "POST",
                    data: { aciton: 'checkstock', pid: pid },
                    timeout: 30000,
                    dataType: "json",
                    success: function (data) {
                        if (data.status == 0) {
                            goto(pid);
                        } else if (data.status == 1) {
                            goto(4);
                        } else {
                            alert(data.msg);
                        }
                    },
                    error: function () {
                    }
                });
            }
            var rotateFunc = function (awards, angle, text) {
                isture = true;
                $btn.stopRotate();
                $btn.rotate({
                    angle: 0,
                    duration: 4000, //旋转时间
                    animateTo: angle + 1440, //让它根据得出来的结果加上1440度旋转
                    callback: function () {
                        isture = false; // 标志为 执行完毕
                        //alert(text);
                        if (awards == 5) {
                            playnum += 1;
                        }
                        if (awards == 1 || awards == 2 || awards == 3) {
                            pid = awards;
                            $("#msg1").show();
                            $("#prdname").text(text);
                            $("#myimg").attr('src', 'img/img' + awards + '.png');
                            if (awards == 3) {
                                $("#des").text("有效期：3个月");
                            }
                        } else {
                            if (awards == 4) {
                                $("#msg2").show();
                            } else {
                                new TipBox({ type: 'tip', str: '恭喜您，再来一次吧！', clickDomCancel: true, setTime: 10000500, hasBtn: true });
                                againplay();
                            }
                        }
                        //                        switch (awards) {
                        //                            case 1:
                        //                                window.location.href = 'result1.html?openid=' + openid;
                        //                                break;
                        //                            case 2:
                        //                                window.location.href = 'result2.html?openid=' + openid;
                        //                                break;
                        //                            case 3:
                        //                                window.location.href = 'result3.html?openid=' + openid;
                        //                                break;
                        //                            case 4:
                        //                                window.location.href = 'result4.html?openid=' + openid;
                        //                                break;
                        //                            case 5:
                        //                                new TipBox({ type: 'tip', str: '恭喜您，再来一次吧！', clickDomCancel: true, setTime: 10000500, hasBtn: true });
                        //                                againplay();
                        //                                break;
                        //                        }
                    }
                });
            };
        });
    </script>
</body>
</html>
